package com.zlx.guguanjia.controller;

import com.zlx.guguanjia.entity.Result;
import com.zlx.guguanjia.entity.Statute;
import com.zlx.guguanjia.service.StatuteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Map;

/**
 * @Author 周罗校
 * @Description
 * @ClassName StatuteController
 * @date 2020.10.29 17:10:34
 * 该版权归周罗校所有，最终解释权以官方为准
 */
@RestController
@RequestMapping("/manager/statute/")
public class StatuteController {

    @Autowired
    private StatuteService service;

    @GetMapping("selectPage/{start}/{pageSize}")
    public Result selectPage(@PathVariable("start") int start, @PathVariable("pageSize") int pageSize, Integer type){
        return new Result(service.selectPage(start,pageSize,type));
    }
    @PutMapping("updateById")
    public Result updateById(@RequestBody Statute statute){
        statute.setUpdateDate(new Date());
        return new Result(service.updateByPrimaryKeySelective(statute));
    }
    @PostMapping("insertStatute")
    public Result insertStatute(@RequestBody Statute statutes){
        statutes.setDelFlag("0");
        statutes.setCreateDate(new Date());
        statutes.setUpdateDate(new Date());
        return new Result(service.insertSelective(statutes));
    }

    //逻辑删除
    @PutMapping("deleteAppVersionById")
    public Result deleteAppVersionById(@RequestBody Statute statute){
        //标记删除了
        statute.setDelFlag("1");
        statute.setUpdateDate(new Date());
        return new Result(service.updateByPrimaryKeySelective(statute));
    }
}
